package com.eascs.admin.o2o.oper.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.eascs.admin.o2o.oper.dao.O2oOperationUploanlogDao;
import com.eascs.admin.o2o.oper.entity.O2oOperationUploanlog;
import com.eascs.admin.o2o.oper.entity.O2oOperationUploanlogForm;
import com.eascs.app.dao.PageResult;

@Service
public class O2oOperationUploanlogService implements IO2oOperationUploanlogService {

	@Autowired
	O2oOperationUploanlogDao dao;
	
	public int insert(O2oOperationUploanlog uploanlog) {
		// TODO Auto-generated method stub
		return dao.insert(uploanlog);
	}

	public int updateById(O2oOperationUploanlog uploanlog) {
		// TODO Auto-generated method stub
		return dao.updateById(uploanlog);
	}

	public int delete(String id) {
		// TODO Auto-generated method stub
		return dao.deleteById(O2oOperationUploanlog.class, id);
	}

	public O2oOperationUploanlog queryById(String id) {
		// TODO Auto-generated method stub
		return dao.getById(O2oOperationUploanlog.class, id);
	}

	public List<O2oOperationUploanlog> queryList(String loanapplyNo) {
		// TODO Auto-generated method stub
		String sql = "select bill_code,up_user_name,up_time,up_remark from o2o_operation_uploanlog where loanapply_no=? ";
		return dao.findEntitys(sql, O2oOperationUploanlog.class, loanapplyNo);
	}

	public PageResult<Object[]> queryBypage(O2oOperationUploanlogForm form) {
		// TODO Auto-generated method stub
		return dao.queryBypage(form);
	}

	public O2oOperationUploanlog queryByLoanapplyNo(String loanapplyNo) {
		// TODO Auto-generated method stub
		String sql ="SELECT id,loanapply_no,bill_code,up_user_no,up_user_name,up_time,up_remark FROM o2o_operation_uploanlog where loanapply_no=? and up_time=(SELECT MAX(up_time) FROM o2o_operation_uploanlog where loanapply_no=?)";
		return dao.findEntity(sql, O2oOperationUploanlog.class, loanapplyNo,loanapplyNo);
	}

}
